import { ScrollPane } from "../../../fl/containers/ScrollPane";
import { IFrUI } from "../core/IFrUI";
import { InvalidationType } from "../../../fl/core/InvalidationType";
import { SkinManager } from "../skins/SkinManager";
import { ObjEventListerTool } from "../utils/ObjEventListerTool";
import { IDispose } from "../../gengine/core/IDispose";
import { UICompomentPool } from "../utils/UICompomentPool";
import { SCROLLBARPOSITIONRIGHT } from "../../../GScrollPane/SCROLLBARPOSITIONRIGHT";
type int = number;
//class GScrollPane
    
    export  class GScrollPane extends ScrollPane implements IFrUI
    {
        constructor()
        {
            
            super();this._styleName = this.CLASSNAME;
            return;
        }

        public get styleName(): string
        {
            return this._styleName;
        }

        public set styleName(arg1: string)
        {
            if (this._styleName != arg1) 
            {
                this._styleName = arg1;
                invalidate(InvalidationType.STYLES);
                this._isStyleChange = true;
            }
            return;
        }

        protected final override draw(): void
        {
            if (isInvalid(InvalidationType.STYLES)) 
            {
                if (this._isStyleChange) 
                {
                    SkinManager.setComponentStyle(this, this._styleName);
                    this._isStyleChange = false;
                }
                this.updateStyle();
            }
            if (isInvalid(InvalidationType.DATA)) 
            {
                this.updateDate();
            }
            if (isInvalid(InvalidationType.SIZE)) 
            {
                this.updateSize();
            }
            if (!isInvalid(InvalidationType.SCROLL)) 
            {
            };
            if (isInvalid(InvalidationType.ALL)) 
            {
                this.updateDisplayList();
            }
            try 
            {
                super.draw();
            }
            catch (e)
            {
            };
            return;
        }

        protected createChildren(): void
        {
            return;
        }

        protected updateStyle(): void
        {
            return;
        }

        protected updateSize(): void
        {
            return;
        }

        protected updateDate(): void
        {
            return;
        }

        protected updateDisplayList(): void
        {
            return;
        }

        public setScrollBarSize(arg1: number): void
        {
            _horizontalScrollBar.setSize(arg1, height);
            _verticalScrollBar.setSize(arg1, height);
            return;
        }

        protected /* override */ drawLayout(): void
        {
            super.drawLayout();
            this.setVerticalScrollBarPosition();
            return;
        }

        public set verticalScrollBarPos(arg1: string)
        {
            this.verticalScrollBarPosition = arg1 == GScrollPane.SCROLLBARPOSITIONLEFT ? GScrollPane.SCROLLBARPOSITIONLEFT : GScrollPane.SCROLLBARPOSITIONRIGHT;
            invalidate(InvalidationType.SCROLL);
            return;
        }

        /* internal  */setVerticalScrollBarPosition(): void
        {
            if (vScrollBar) 
            {
                if (this.verticalScrollBarPosition != GScrollPane.SCROLLBARPOSITIONRIGHT) 
                {
                    _verticalScrollBar.x = 0;
                    contentClip.x = contentClip.x + _verticalScrollBar.width;
                }
                else 
                {
                    _verticalScrollBar.x = width - _verticalScrollBar.width;
                }
            }
            _verticalScrollBar.visible = vScrollBar;
            return;
        }

        public configEventListener(arg1: string, arg2: Function, arg3: Boolean=false, arg4: int=0, arg5: Boolean=false): void
        {
            ObjEventListerTool.addObjEvent(this, arg1, arg2, arg3);
            addEventListener(arg1, arg2, arg3, arg4, arg5);
            return;
        }

        public /* override */ removeEventListener(arg1: string, arg2: Function, arg3: Boolean=false): void
        {
            ObjEventListerTool.removeObjEvent(this, arg1, arg2, arg3);
            super.removeEventListener(arg1, arg2, arg3);
            return;
        }

        public dispose(arg1: Boolean=true): void
        {
            var loc2=0;
            var loc3=null;
            ObjEventListerTool.delObjEvent(this);
            var loc1=this.numChildren;
            --loc2;
            while (loc2 >= 0) 
            {
                if ((loc3 = this.getChildAt(loc2)) is IDispose) 
                {
                    this.removeChild(loc3);
                    (loc3 as IDispose).dispose(arg1);
                }
                --loc2;
            }
            if (this.parent) 
            {
                this.parent.removeChild(this);
            }
            if (arg1) 
            {
                UICompomentPool.disposeUICompoment(this);
            }
            return;
        }

        public /* const */CLASSNAME: string="ScrollPane";

        public static /* const */SCROLLBARPOSITIONLEFT: string="left";

        public static /* const */SCROLLBARPOSITIONRIGHT: string="right";

        private /* var */verticalScrollBarPosition: string="right";

        private /* var */_styleName: string="";

        private /* var */_isStyleChange: Boolean=false;
    }
